package T03_ThreadState;

import java.util.concurrent.TimeUnit;

public class S005 {
  public static void main(String[] args) throws InterruptedException {
    Thread t1 = new Thread(() -> {
      while (true) {
        try {
          // 在死循环中 每间隔2s之后 执行一次
          TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
          throw new RuntimeException(e);
        }
        System.out.println("更新中...");
      }
    });
    
    t1.start();
    // 间隔1s 执行之后 子线程处于sleep 状态
    TimeUnit.SECONDS.sleep(1);
    System.out.println(t1.getState());
  }
}
